<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="Keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" type="image/x-icon" href="/static/images/favicon.ico">

	<title>添加异动记录-异动管理-<{$user_data['school_name']}>-德安信会计在线教育平台</title>
	<link href="/static/school/css/layout.css" type="text/css" rel="stylesheet" />
    <script src="/static/public/jquery-1.11.1.min.js" type="text/javascript"></script>
	<link href="/static/school/css/frame.style.css" type="text/css" rel="stylesheet" />
    <link href="/static/school/css/default.style.css" type="text/css" rel="stylesheet" />
    <link href="/static/public/layer/src/css/layui.css" rel="stylesheet">
	<script>
	$(function(){
		$("#btn_save").click(function(){
			$("form").submit();
		});
	})
	</script>
</head>
<body>
	<div class="wrap">
		<!--star left-->
		<div class="column">
			<{include file="left_menu.html"}>
		</div>
		<div id="ContMianBox">
			<!--star子栏目-->
			<div class="sub-colum">
                <div class="tit"><{$left_menu_min.menu}></div>
                <ul>
                    <{foreach from=$left_menu_min.list item=item}>
                    <li <{if $item['url'] == $left_menu_min.curr}>class="curr"<{/if}>><a href="<{$item['url']}>"><{$item['name']}></a></li>
                    <{/foreach}>
                </ul>
            </div>
			<!--end子栏目-->

			<!--end left-->
			<div class="container narrow">
			    <!--star conter-->
			    <div class="cetContent">
					<div class="tit p-lr20">
						<span ><a href="/chuqin/today_class">今日上课</a></span>
						<span ><a href="/chuqin/today_signin">今日签到</a></span>
						<span ><a href="/chuqin/leave_list">请假管理</a></span>
						<span class="curr">异动管理</span>
					</div>
					<!--star内容区域-->
					<div class="mainScroll">
					    <div class="mainContainer line-all">

					        <div class="tabMainCont">

					            <!--star 编辑基本信息-->
					            <div class="tabItem step-02">

										<form action="/chuqin/change_add" method="post" class="layui-form">
										<div class="layui-form-item">
									    <label class="layui-form-label">所在校区：</label>
											<div class="layui-input-inline">
												<select name="campus" id="campus" style="width: 500px;" lay-filter="campus" lay-verify="required">
													<option value="">所在校区</option>
													<{if isset($campus_list)}>
													<{foreach from=$campus_list item=item}>
													<option value="<{$item['id']}>"><{$item['name']}></option>
													<{/foreach}>
													<{/if}>
												</select>
									  		</div>
									  </div>


										<div class="layui-form-item">
									      <label class="layui-form-label">学员：</label>
									      <div class="layui-input-inline">
									        <select name="student_id" id="student_id" lay-filter="student_id"  lay-verify="required" lay-search="">
									          <option value="">搜索学员</option>
									          <{if isset($student_list)}>
									          <{foreach from=$student_list item=item}>
									          <option value="<{$item['student_id']}>"><{$item['name']}></option>
									          <{/foreach}>
									          <{/if}>
									        </select>
									      </div>
									    </div>

										 <div class="layui-form-item">
									    <label class="layui-form-label">所在班级：</label>
											<div class="layui-input-inline">
													<select name="class_id" id="class_id" style="width: 500px;" lay-filter="class_id" >
													<option value="">所在班级</option>

												</select>
									  	</div>
									  </div>
					<div class="layui-form-item">
						<label class="layui-form-label">异动类型：</label>
						<div class="">
						<input type="radio" lay-filter="change_type" name="change_type" value="5" title="转校区" >
						<input type="radio" lay-filter="change_type" name="change_type" value="1" title="转班" >
					      <input type="radio" lay-filter="change_type" name="change_type" value="2" title="休学">
					      <input type="radio" lay-filter="change_type" name="change_type" value="3" title="退学">
					      <input type="radio" lay-filter="change_type" name="change_type" value="4" title="弃学">
						</div>
					</div>


					<div class="layui-form-item layui-form-text" id="zhuanxiao_html" style="display: none;">
						 <label class="layui-form-label">新校区：</label>
						<div class="layui-input-inline">
							<select name="new_campus" id="new_campus" style="width: 500px;" lay-filter="new_campus">
								<option value="">新校区</option>
								<{if isset($campus_list)}>
								<{foreach from=$campus_list item=item}>
								<option value="<{$item['id']}>"><{$item['name']}></option>
								<{/foreach}>
								<{/if}>
							</select>
				  		</div>
					 </div>

					 <div class="layui-form-item layui-form-text" id="zhuanban_html" style="display: none;">
						 <label class="layui-form-label">新班级：</label>
						<div class="layui-input-inline">
							<select name="new_class" id="new_class" style="width: 500px;" lay-filter="new_class" >
								<option value="">新班级</option>

							</select>
				  		</div>
					 </div>

										<div class="layui-form-item layui-form-text">
										 <label class="layui-form-label">异动说明：</label>
										 <div class="layui-input-block">
											 <textarea placeholder="异动说明" style="width:500px"  name="remark" class="layui-textarea"><{if isset($remark)}><{$remark}><{/if}></textarea>
											 <{if isset($remark_err)}>
											 <i class="layui-icon" style="font-size: 30px; color: red">&#x1007;</i>
											 <{$remark_err}>
											 <{/if}>
										 </div>

										</div>

										<d
										<div class="layui-form-item">
										 <div class="layui-input-block">
											 <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
											 <button type="reset" class="layui-btn layui-btn-primary">取消</button>
										 </div>
										</div>


	            </form>
					            </div>
					            <!--end 编辑基本信息-->

					        </div>


					    </div>
					</div>
					</div>
					<!--end内容区域-->

		    <!--end conter-->
		</div>


	</div>
</div>
<{include file="footer.html"}>
<script>
	layui.use(['form','laydate','jquery'], function(){
		var laydate = layui.laydate;
		var form = layui.form(),$ = layui.jquery;


		//学员
		form.on('select(student_id)',function(data){
			var ii = layer.load();
			// alert(data.value);
			var student_id = data.value;
			$("#class_id").html('<option value="">请选择班级</option>');
			form.render('select');
			$.ajax({
				type: "POST",
				url: "/ajax_jiaowu/get_class_by_student/"+student_id,
				dataType:"json",
				success: function(result){
					var html ='';
					$.each(result, function(i, obj) {
						html += '<option value="'+obj.id+'">'+obj.class_name+'</option>';
					});
					$("#class_id").append(html);
					form.render('select');
					layer.close(ii);
				}
			});
		});

		//校区
		form.on('select(campus)',function(data){
			var ii = layer.load();
			// alert(data.value);
			var campus_id = data.value;
			$("#student_id").html('<option value="">请搜索学员</option>');
			form.render('select');
			$.ajax({
				type: "POST",
				url: "/ajax_jiaowu/get_student_by_campus/"+campus_id,
				dataType:"json",
				success: function(result){
					var html ='';
					$.each(result, function(i, obj) {
						html += '<option value="'+obj.student_id+'">'+obj.name+'</option>';
					});
					$("#student_id").append(html);
					form.render('select');
					layer.close(ii);
				}
			});

			$("#new_class").html('<option value="">新班级</option>');
			$.ajax({
				type: "POST",
				url: "/ajax_jiaowu/get_class_by_campus/"+campus_id,
				dataType:"json",
				success: function(result){
					var html ='';
					$.each(result, function(i, obj) {
						html += '<option value="'+obj.id+'">'+obj.class_name+'</option>';
					});
					$("#new_class").append(html);
					form.render('select');
					layer.close(ii);
				}
			});

		});

		//异动类型
		form.on('radio(change_type)', function(data){

			var change_type = data.value;
			if(change_type == 5 ){
				//转校判断
				var campus = $("#campus").val();
				if(campus==""){
					alert("请选择校区");
					$(data.elem).attr('checked',false);
					form.render('radio');
					return;
				}
				var student = $("#student_id").val();
				if(student==""){
					alert("请选择学员");
					$(data.elem).attr('checked',false);
					form.render('radio');
					return;
				}
				$("#zhuanban_html").hide();
				$("#zhuanxiao_html").show();

			}
			if(change_type  ==1){
				var campus = $("#campus").val();
				if(campus==""){
					alert("请选择校区和班级");
					$(data.elem).attr('checked',false);
					form.render('radio');
					return;
				}
				var student = $("#student_id").val();
				if(student==""){
					alert("请选择学员");
					$(data.elem).attr('checked',false);
					form.render('radio');
					return;
				}
				var class_id = $("#class_id").val();
				if(class_id==""){
					alert("请选择班级");
					$(data.elem).attr('checked',false);
					form.render('radio');
					return;
				}
				//转班
				$("#zhuanxiao_html").hide();
				$("#zhuanban_html").show();
			}

		});


		//提交表单
		form.on('submit(*)', function(data){
			 var change_type = $('input[name="change_type"]:checked').val();
			 // alert(change_type);
			 if(change_type == ""||change_type==undefined){
			 	layer.msg('请选择异动类型');
			     return false;
			 }else{
			 	if(change_type == 5){
			 		//转校
			 		var new_campus = data.field.new_campus;
			 		if(new_campus == ""){
			 			//请选择校区
			 			layer.msg('请选择新校区');
			     		return false;
			 		}
			 	}
			 	else if(change_type == 1){
			 		//转班
			 		var new_class = data.field.new_class;
			 		if(new_class == ""){
			 			//请选择校区
			 			layer.msg('请选择新班级');
			     		return false;
			 		}
			 	}
			 }
		  return true;
		});

	});
</script>

</body>
</html>
